package com.example.utils;

import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data//getset
@NoArgsConstructor//无参
public class Resss implements Serializable{
    private Integer code;
    private String message;
    private Map<String,Object> data=new HashMap<>();

    public Resss code(Integer code){
        this.code=code;
        return this;
    }

    public Resss message(String message){
        this.message=message;
        return this;
    }

    public Resss data(String key,Object value){
        this.data.put(key,value);
        return this;
    }
    public Resss data(Map map){
        this.data=map;
        return this;
    }

    public static Resss error(Integer code,String message){
        Resss r=new Resss();
        r.setCode(code);
        r.setMessage(message);
        return r;
    }
}